<template>
    <div class="edit-standards1">
        <div class="standards-title">基本信息</div>
        <div class="information-content">
            <div class="block-box">
                <span class="block-item">
                    <span class="item-name">所属上级：</span>
                    <span class="item-value">
                        <el-input v-model="form.parentName" :disabled="true"></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">名称：</span>
                    <span class="item-value">
                        <el-input v-model="form.name" ></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">编码：</span>
                    <span class="item-value">
                        <el-input v-model="form.code" :disabled="true"></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">考核分值：</span>
                    <span class="item-value">
                        <el-input v-model="form.score"></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">法律法规：</span>
                    <span class="item-value">
                        <el-input type="textarea" :rows="2" v-model="form.laws" ></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">备注：</span>
                    <span class="item-value">
                        <el-input type="textarea" :rows="2" v-model="form.remark" ></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">引用地址：</span>
                    <span class="item-value">
                        <el-input v-model="form.lawsUrl" ></el-input>
                    </span>
                </span>
                <span class="block-item">
                    <span class="item-name">考核明细：</span>
                    <span class="item-value">
                        <i class="el-icon-document" @click="getkhmx()"></i>
                    </span>
                </span>
            </div>
        </div>

        <!--考核明细弹出层-->
        <el-dialog
                :title="dialogTitle2"
                :visible.sync="dialogVisible2"
                width="40%"
                v-dialogDrag
                v-if="dialogVisible2"
                :close-on-click-modal="false">
            <div class="dialog-content" v-loading="dialogLoading" style="flex-direction: column;">
                <div class="operate-btn" style="margin: 0 0 0.1875rem 0;">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="khmxdialog(0)">新增</el-button>
                </div>
                <div class="table-list">
                    <el-table
                            :data="khmxtableData"
                            border
                            height="100%">
                        <el-table-column
                                label="考核明细"
                                prop="detailContent"
                                align="center"
                                show-overflow-tooltip/>
                        <el-table-column
                                label="操作"
                                align="center"
                                class-name="small-padding fixed-width">
                            <template slot-scope="scope">
                                <el-button size="mini" type="text" icon="el-icon-edit"  @click="khmxdialog(1, scope.row)">编辑</el-button>
                                <el-button size="mini" type="text" icon="el-icon-close" @click="deletekhmx(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <div class="dialog-footer">
                <el-button size="small" @click="dialogVisible2 = false">取 消</el-button>
            </div>
        </el-dialog>
        <!--新增考核明细弹出层-->
        <el-dialog
                :title="dialogTitle3"
                :visible.sync="dialogVisible3"
                width="40%"
                v-dialogDrag
                v-if="dialogVisible3"
                :close-on-click-modal="false">
            <div class="dialog-content" v-loading="dialogLoading" style="flex-direction: column;">
                <div class="line-item">
                    <span class="item-name"><i>*</i>明细内容：</span>
                    <span class="item-value">
                        <el-input type="textarea" :rows="6" placeholder="请输入内容" v-model="detailContent"></el-input>
                    </span>
                </div>
            </div>
            <div class="dialog-footer">
                <el-button type="primary" size="small" v-if="addShow" @click="addkhmx()" :disabled="dialogLoading">确 定</el-button>
                <el-button type="primary" size="small" v-if="editShow" @click="editkhmx()" :disabled="dialogLoading">确 定</el-button>
                <el-button size="small" @click="dialogVisible3 = false">取 消</el-button>
            </div>
        </el-dialog>


        <div class="preserve-btn">
            <el-button type="success" size="small" @click="saveTwoType" icon="el-icon-check">保存</el-button>
            <el-button type="danger" size="small" icon="el-icon-close" @click="closeTab()">关闭</el-button>
        </div>

        <!--底部的新增和表格-->
        <div class="content-area">
            <div class="operate-btn">
                <el-button type="primary" icon="el-icon-plus" size="mini" @click="addEvaluation()">新增</el-button>
            </div>
            <div class="table-list">
                <el-table
                        :data="tableData"
                        border
                        height="100%">
                    <el-table-column
                            label="立案条件"
                            prop="starConditions"
                            align="center"
                            show-overflow-tooltip/>
                    <el-table-column
                            label="编码"
                            prop="code"
                            align="center"/>
                    <el-table-column label="可选处置时限" align="center">
                        <el-table-column
                                label="A类"
                                prop=""
                                align="center" :formatter="formatA"/>
                        <el-table-column
                                label="B类"
                                prop=""
                                align="center" :formatter="formatB"/>
                        <el-table-column
                                label="C类"
                                prop=""
                                align="center" :formatter="formatC"/>
                    </el-table-column>
                    <el-table-column
                            label="结案条件"
                            prop="endsConditions"
                            align="center"/>
                    <el-table-column
                            label="归属部门"
                            prop="deptName"
                            align="center"/>
                    <el-table-column
                            label="责任主体"
                            prop="parentDeptName"
                            align="center"/>
                    <el-table-column
                            label="案件说明"
                            prop="instructions"
                            align="center"
                            show-overflow-tooltip/>
                    <el-table-column
                            label="操作"
                            align="center"
                            width="100"
                            class-name="small-padding fixed-width">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>

        <!--新增弹出层-->
        <el-dialog
                :title="dialogTitle1"
                :visible.sync="dialogVisible"
                width="50%"
                v-dialogDrag
                v-if="dialogVisible"
                :close-on-click-modal="false">
            <div class="dialog-content" v-loading="dialogLoading">
                <!--<el-form :model="addForm" ref="addForm">-->
                    <div class="line-item line-itemW">
                        <span class="item-name">一级：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.parentName" disabled></el-input>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name">二级：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.name" disabled></el-input>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name">代码：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.code" disabled></el-input>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>是否突发：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.isTf" placeholder="">
                                <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>是否延期：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.isYq" placeholder="">
                               <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>是否缓办：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.isHb" placeholder="">
                                <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>责任主体：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.parentDeptCode" size="small"  @change="getDepartment">
                                <el-option
                                        v-for="item in addForm.responsibleData"
                                        :label="item.name"
                                        :value="item.code"
                                        :key="item.code">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>部门：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.deptCode" size="small" :disabled="addForm.parentDeptCode===''?true:false" @change="getPrimarylist">
                                <el-option
                                        v-for="item in addForm.departmentData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.code">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>一级行业：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.primaryIndustry" size="small" :disabled="addForm.deptCode===''?true:false" @change="getSecondarylist">
                                <el-option
                                        v-for="item in addForm.primaryIndustryData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>二级行业：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.secondaryIndustry" size="small" :disabled="addForm.primaryIndustry===''?true:false">
                                <el-option
                                        v-for="item in addForm.secondaryIndustryData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item line-itemW">
                        <span class="item-name"><i>*</i>是否紧急：</span>
                        <span class="item-value">
                            <el-select v-model="addForm.isJj" placeholder="">
                               <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item itemABC">
                        <span class="item-name"><i>*</i>A类：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.timesA"></el-input>
                            <el-select v-model="addForm.timesUnitA" placeholder="">
                                <el-option
                                        v-for="item in addForm.timesUnitData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.code">
                                </el-option>
                            </el-select>
                            <el-select v-model="addForm.timesTypeA" placeholder="">
                               <el-option
                                       v-for="item in addForm.timesTypeData"
                                       :key="item.value"
                                       :label="item.name"
                                       :value="item.code">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item itemABC">
                        <span class="item-name"><i>*</i>B类：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.timesB"></el-input>
                            <el-select v-model="addForm.timesUnitB" placeholder="">
                                <el-option
                                        v-for="item in addForm.timesUnitData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.code">
                                </el-option>
                            </el-select>
                            <el-select v-model="addForm.timesTypeB" placeholder="">
                                <el-option
                                        v-for="item in addForm.timesTypeData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.code">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item itemABC">
                        <span class="item-name"><i>*</i>C类：</span>
                        <span class="item-value">
                            <el-input v-model="addForm.timesC"></el-input>
                            <el-select v-model="addForm.timesUnitC" placeholder="">
                                <el-option
                                        v-for="item in addForm.timesUnitData"
                                        :key="item.value"
                                        :label="item.name"
                                        :value="item.code">
                                </el-option>
                            </el-select>
                            <el-select v-model="addForm.timesTypeC" placeholder="">
                                 <el-option
                                         v-for="item in addForm.timesTypeData"
                                         :key="item.value"
                                         :label="item.name"
                                         :value="item.code">
                                </el-option>
                            </el-select>
                        </span>
                    </div>
                    <div class="line-item">
                        <span class="item-name"><i>*</i>立案条件：</span>
                        <span class="item-value">
                            <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.starConditions"></el-input>
                        </span>
                    </div>
                    <div class="line-item">
                        <span class="item-name"><i>*</i>结案条件：</span>
                        <span class="item-value">
                            <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.endsConditions"></el-input>
                        </span>
                    </div>
                    <div class="line-item">
                        <span class="item-name">案件说明：</span>
                        <span class="item-value">
                            <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.instructions"></el-input>
                        </span>
                    </div>
                <!--</el-form>-->
            </div>
            <div class="dialog-footer">
                <el-button type="primary" size="small" @click="addTypeLeveThree" :disabled="dialogLoading">确 定</el-button>
                <el-button size="small" @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import {getArchivesTypeLeveTwoById, getArchivesTypeLeveThreeList ,insertArchivesTypeLeveThree, getThreeCode, getListData, getcaseType, getcategoryName, getsubclassName, getresponsible, getdepartment, getprimaryIndustry, getsecondaryIndustry,getarchivesTypeLeveList,getTimesUnitList,getTimesTypeList, saveArchivesTypeLeveTwo, getArchivesTypeLeveTwoAssessmentList, addArchivesTypeLeveTwoAssessment, saveAssessment, delAssessment} from '@/api/configure/configure'
    export default {
        name: 'Editstandards1',
        data(){
            return {
                // 弹出层加载
                dialogLoading: false,
                loading:true,
                form:{/*
                    parentId:'',
                    parentName:'',
                    name:'',
                    code:'',
                    score:'',
                    laws:'',
                    remark:'',
                    lawsUrl:'',*/
                },
                tableData:[],
                dialogTitle1:'添加立案标准',
                dialogVisible:false,
                //考核明细
                dialogTitle2:'考核明细列表',
                dialogVisible2:false,
                khmxtableData:[],
                //新增考核明细
                dialogTitle3:'新增考核明细列',
                dialogVisible3:false,
                //控制新增按钮是否出现
                addShow:true,
                //控制编辑按钮是否出现
                editShow:false,
                //新增和修改的明细内容
                detailContent:'',//明细内容
                //新增的id
                parentId:this.$route.query.id,
                //编辑的id
                id:'',
                addForm:{
                    parentId:this.$route.query.id,
                    parentName:'',
                    name:'',
                    code:'',
                    isHb:'0',
                    isJj:'0',
                    isTf:'0',
                    isYq:'0',
                    //归属部门
                    deptCode:'',
                    departmentData: [],
                    //一级行业
                    primaryIndustry: '',
                    primaryIndustryData: [],
                    //二级行业
                    secondaryIndustry: '',
                    secondaryIndustryData: [],
                    //责任主体
                    parentDeptCode:'',
                    responsibleData: [],
                    timesA:'',
                    timesB:'',
                    timesC:'',
                    timesUnitA:'1',
                    timesUnitB:'1',
                    timesUnitC:'1',
                    timesTypeA:'2',
                    timesTypeB:'2',
                    timesTypeC:'2',
                    timesUnitData:[],
                    timesTypeData:[],
                    //立案条件
                    starConditions:'',
                    //结案条件
                    endsConditions:'',
                    //案件说明
                    instructions:''
                },
            }
        },
        created(){
            //初始化信息和表格数据
            this.getArchivesTypeLeveTwo();
            this.getArchivesTypeLeveThreeList();
            this.getSubject();
        },
        methods:{
            /**
             * Description:根据id获取二级类
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            getArchivesTypeLeveTwo(type){
                getArchivesTypeLeveTwoById(this.$route.query.id).then(
                    (res) => {
                        this.form = res.data;
                        if (type === 0) {
                            this.$message.success('保存成功')
                        }
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });

            },
            //修改二级综合评级标准
            saveTwoType(){
                saveArchivesTypeLeveTwo(this.form).then(
                    (res) => {
                        this.getArchivesTypeLeveTwo(0);
                        this.dialogVisible = false;
                        this.closeTab();
                    }
                ).catch((error) => {
                    console.log(error, 'saveArchivesTypeLeveTwo');
                });
            },
            //考核明细表弹出层
            getkhmx(){
                this.dialogVisible2 = true;
                this.getkhmxList();
            },
            //新增考核明细弹出层
            khmxdialog(type,row){
                this.dialogVisible3 = true;
                if(type === 0){
                    this.dialogTitle3 = '新增明细内容';
                    this.detailContent = '';
                    this.addShow = true;
                    this.editShow = false;
                }
                if(type === 1){
                    this.dialogTitle3 = '编辑明细内容';
                    this.detailContent = row.detailContent;
                    this.id=row.id;
                    this.addShow = false;
                    this.editShow = true;
                }
            },
            //保存新增明细
            addkhmx(){
                this.dialogLoading = true;
                if(this.detailContent === ''){
                    this.$message.error('请输入明细内容');
                    this.dialogLoading = false;
                    return
                }
                let data = {
                    detailContent:this.detailContent,
                    parentId:this.parentId
                };
                addArchivesTypeLeveTwoAssessment(data).then(
                    (res) => {
                        this.dialogVisible3 = false;
                        this.dialogLoading = false;
                        this.$message.success('新增成功');
                        this.getkhmxList();
                    }
                ).catch((error) => {
                    this.dialogLoading = false;
                    console.log(error, 'addArchivesTypeLeveTwoAssessment');
                });
            },
            //修改明细内容
            editkhmx(){
                this.dialogLoading = true;
                if(this.detailContent === ''){
                    this.$message.error('请输入明细内容');
                    this.dialogLoading = false;
                    return
                }
                let data = {
                    detailContent:this.detailContent,
                    id:this.id
                };
                saveAssessment(data).then(
                    (res) => {
                        this.dialogVisible3 = false;
                        this.dialogLoading = false;
                        this.$message.success('修改成功');
                        this.getkhmxList();
                    }
                ).catch((error) => {
                    this.dialogLoading = false;
                    console.log(error, 'saveAssessment');
                });
            },
            //删除考核明细
            deletekhmx(row){
                this.$confirm('确定删除该条明细内容吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    center: true
                }).then(() => {
                    this.dialogLoading = true;
                    delAssessment({id:row.id}).then(
                        (res) => {
                            this.dialogLoading = false;
                            this.$message.success('删除成功');
                            this.getkhmxList();
                        }
                    ).catch((error)=>{
                        this.dialogLoading = false;
                        console.log(error, 'delAssessment');
                    })
                }).catch(() => {
                    this.$message.info('已取消删除');
                });
            },
            //获取考核明细表
            getkhmxList(){
                this.dialogLoading = true;
                getArchivesTypeLeveTwoAssessmentList({id:this.$route.query.id}).then(
                    (res) => {
                        this.khmxtableData = res.data;
                        this.dialogLoading = false;
                    }
                ).catch((error) => {
                    this.dialogLoading = false;
                    console.log(error, 'getArchivesTypeLeveTwoAssessmentList');
                });
            },
            /**
             * Description:根据id获取三级列表
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            getArchivesTypeLeveThreeList(type){
                getArchivesTypeLeveThreeList(this.$route.query.id).then(
                    (res) => {
                        this.tableData = res.data;
                        if (type === 0) {
                            this.$message.success('新增成功')
                        }
                    }
                ).catch((error) => {
                    console.log(error, 'getArchivesTypeLeveThreeList');
                });
            },
            formatA(value){
                let content = '';
                let data = value.archivesDisposal;
                if (data.length > 0) {
                    for (let i = 0; i < data.length; i++) {
                        if (data[i].disposalType == "A") {
                            content += data[i].times;
                            if (data[i].timesType == 1) {
                                content += "紧急";
                            }
                            if (data[i].timesUnit == 1) {
                                content += "工作时"
                            }
                            if (data[i].timesUnit == 2) {
                                content += "工作日"
                            }
                            break;
                        }
                    }
                }
                return content;
            },
            formatB(value){
                let content = '';
                let data = value.archivesDisposal;
                if (data.length > 0) {
                    for (let i = 0; i < data.length; i++) {
                        if (data[i].disposalType == "B") {
                            content += data[i].times;
                            if (data[i].timesType == 1) {
                                content += "紧急";
                            }
                            if (data[i].timesUnit == 1) {
                                content += "工作时"
                            }
                            if (data[i].timesUnit == 2) {
                                content += "工作日"
                            }
                            break;
                        }
                    }
                }
                return content;
            },
            formatC(value){
                let content = '';
                let data = value.archivesDisposal;
                if (data.length > 0) {
                    for (let i = 0; i < data.length; i++) {
                        if (data[i].disposalType == "C") {
                            content += data[i].times;
                            if (data[i].timesType == 1) {
                                content += "紧急";
                            }
                            if (data[i].timesUnit == 1) {
                                content += "工作时"
                            }
                            if (data[i].timesUnit == 2) {
                                content += "工作日"
                            }
                            break;
                        }
                    }
                }
                return content;
            },
            /**
             * Description:新增考核明细
             * Author:cy
             * Date:2020/9/22
             * @param
             */
            addTypeLeveThree(){
                if (this.addForm.parentDeptCode === '') {
                    this.$message.error('请选择责任主体');
                    this.dialogLoading = false;
                    return
                } else if (this.addForm.deptCode === '') {
                    this.$message.error('请选择部门');
                    this.dialogLoading = false;
                    return
                } else if (this.addForm.primaryIndustry === '') {
                    this.$message.error('请选择一级行业');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.secondaryIndustry === '') {
                    this.$message.error('请选择二级行业');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.timesA === '') {
                    this.$message.error('请添加A类');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.timesB === '') {
                    this.$message.error('请添加B类');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.timesC === '') {
                    this.$message.error('请添加C类');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.starConditions === '') {
                    this.$message.error('请添加立案条件');
                    this.dialogLoading = false;
                    return
                }else if (this.addForm.endsConditions === '') {
                    this.$message.error('请添加结案说明');
                    this.dialogLoading = false;
                    return
                }

                if (this.addForm.timesA !== '') {
                    let parnt = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
                    if( !parnt.test(this.addForm.timesA) ){
                        this.$message.error('A类必须为大于0的数字！');
                        this.dialogLoading = false;
                        return
                    }
                }
                if (this.addForm.timesB !== '') {
                    let parnt = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
                    if( !parnt.test(this.addForm.timesB) ){
                        this.$message.error('B类必须为大于0的数字！');
                        this.dialogLoading = false;
                        return
                    }
                }
                if (this.addForm.timesC !== '') {
                    let parnt = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
                    if( !parnt.test(this.addForm.timesC) ){
                        this.$message.error('C类必须为大于0的数字！');
                        this.dialogLoading = false;
                        return
                    }
                }

                insertArchivesTypeLeveThree(this.addForm).then(
                    (res) => {
                        this.getArchivesTypeLeveThreeList(0);
                        this.dialogVisible = false;
                        //清空表格
                        this.addForm.deptCode='';
                        this.addForm.primaryIndustry='';
                        this.addForm.secondaryIndustry='';
                        this.addForm.parentDeptCode='';
                        this.addForm.timesA='';
                        this.addForm.timesB='';
                        this.addForm.timesC='';
                        this.addForm.starConditions='';
                        this.addForm.endsConditions='';
                        this.addForm.instructions='';
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            /**
             * Description:打开新增弹出层
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            addEvaluation(){
                this.dialogVisible=true;
                this.dialogLoading = true;
                this.addForm.parentId = this.$route.query.id;
                this.addForm.parentName = this.form.parentName;
                this.addForm.name = this.form.name;

                this.dialogLoading = false;

                //清空表格
                this.addForm.deptCode='';
                this.addForm.departmentData=[];
                this.addForm.primaryIndustry='';
                this.addForm.primaryIndustryData=[];
                this.addForm.secondaryIndustry='';
                this.addForm.secondaryIndustryData=[];
                this.addForm.parentDeptCode='';
                this.addForm.responsibleData=[];
                this.addForm.timesA='';
                this.addForm.timesB='';
                this.addForm.timesC='';
                this.addForm.starConditions='';
                this.addForm.endsConditions='';
                this.addForm.instructions='';

                this.getthreeCode();
                this.getTimesUnitList();
                this.getTimesTypeList();
                this.getSubject();
            },
            /**
             * Description:获取工作单位字典
             * Author:cy
             * Date:2020/9/22
             * @param
             */
            getTimesUnitList(){
                getTimesUnitList().then(
                    (res) => {
                        this.addForm.timesUnitData = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'getTimesUnitList');
                });
            },
            /**
             * Description:获取工作实效字典
             * Author:cy
             * Date:2020/9/22
             */
            getTimesTypeList(){
                getTimesTypeList().then(
                    (res) => {
                        this.addForm.timesTypeData = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            //获取责任主体
            getSubject(){
                this.loading = true;
                getresponsible().then(
                    (res) => {
                        this.addForm.responsibleData = res.data;
                        this.loading = false;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            /**
             * Description:获取归属部门
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            getDepartment(){
                if(this.addForm.parentDeptCode === ''){
                    this.addForm.deptCode='';
                    this.addForm.primaryIndustry='';
                    this.addForm.secondaryIndustry = '';
                    return;
                }
                this.addForm.deptCode='';
                this.addForm.departmentData=[];
                getdepartment({parentId:this.addForm.parentDeptCode}).then(
                    (res) => {
                        this.addForm.departmentData = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            /**
             * Description:获取一级部门
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            getPrimarylist(){
                if(this.addForm.deptCode === ''){
                    this.addForm.primaryIndustry='';
                    this.addForm.secondaryIndustry = '';
                    return;
                }
                this.addForm.primaryIndustry='';
                this.addForm.primaryIndustryData=[];
                getprimaryIndustry(this.addForm.deptCode).then(
                    (res) => {
                        this.addForm.primaryIndustryData = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            /**
             * Description:获取二级部门
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            getSecondarylist(){
                if(this.addForm.primaryIndustry === ''){
                    this.addForm.secondaryIndustry = '';
                    return;
                }
                this.addForm.secondaryIndustry = '';
                this.addForm.secondaryIndustryData=[];
                getsecondaryIndustry(this.addForm.primaryIndustry).then(
                    (res) => {
                        this.addForm.secondaryIndustryData = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            //获取三级code
            getthreeCode(){
                let parentId=this.$route.query.id;
                getThreeCode(parentId).then(
                    (res) => {
                        this.addForm.code = res.data;
                    }
                ).catch((error) => {
                    console.log(error, 'url');
                });
            },
            /**
             * Description:点击编辑事件
             * Author:cy
             * Date:2020/9/21
             * @param
             */
            handleUpdate(row){
                this.$router.replace({
                    path: "/evaluation/EditStandards2",
                    name: 'EditStandards2',
                    params: {
                        standardsData: row
                    }
                });
            },
            //点击关闭按钮
            closeTab(){
                //关闭详情标签
                let viewsTabs=this.visitedViews;
                for(let i=0;i<viewsTabs.length;i++){
                    if(viewsTabs[i].path == '/evaluation/editstandards1/'){
                        this.$router.replace({
                            path: "/evaluation/index",
                            name:'Evaluation'
                        });
                        this.closeSelectedTag(viewsTabs[i]);
                    }
                }
            },
            //关闭当前标签
            closeSelectedTag(view) {
                this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
                    if (this.isActive(view)) {
                        this.toLastView(visitedViews, view)
                    }
                })
            },
            refreshSelectedTag(view) {
                this.$store.dispatch('tagsView/delCachedView', view).then(() => {
                    const { fullPath } = view;
                    this.$nextTick(() => {
                        this.$router.replace({
                            path: '/redirect' + fullPath
                        })
                    })
                })
            },
            isActive(route) {
                return route.path === this.$route.path
            },
            toLastView(visitedViews, view) {
                const latestView = visitedViews.slice(-1)[0];
                if (latestView) {
                    this.$router.push(latestView.fullPath)
                } else {
                    if (view.name === 'Dashboard') {
                        this.$router.replace({ path: '/redirect' + view.fullPath })
                    } else {
                        this.$router.push('/')
                    }
                }
            },
        },
        computed:{
            timelineImages(){
                for(let i=0;i<this.eventLogList.length;i++){
                    if(this.eventLogList[i].images.length > 0){
                        return this.eventLogList[i].images;
                    }else{
                        return [];
                    }
                }
            },
            visitedViews() {
                return this.$store.state.tagsView.visitedViews
            },
        },
    }
</script>

<style scoped lang="scss">
    .edit-standards1{
        width:100%;
        height:100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: #fff;
        padding:0.125rem;
        .standards-title{
            font-size: 0.1875rem;
            color: #6379bb;
            border-bottom: 0.0125rem solid #ddd;
            margin: 8px 0.125rem 0.3125rem 0.125rem;
            padding-bottom: 0.0625rem;
        }
        .operate-btn{
            margin:0.1875rem 0;
        }
        .information-content {
            display: flex;
            flex-direction: column;
            padding: 0.125rem 0 0.125rem 0.375rem;
            font-size: 0.175rem;
            .block-box {
                display: flex;
                flex-direction: row;
                flex-wrap: wrap;
                padding-right: 10%;
            }

            .block-item {
                width: 50%;
            }

            .block-item, .line-item {
                display: flex;
                flex-direction: row;
                white-space: nowrap;
                margin-bottom: 0.1875rem;

                .item-name {
                    width: 30%;
                    min-width: 1.25rem;
                }

                .item-name, .item-name-small, .line-name {
                    padding-right: 0.125rem;
                    text-align: right;
                    line-height: 0.425rem;

                    i {
                        color: #f00;
                        padding-right: 0.0375rem;
                    }
                }

                .item-name-small {
                    width: 1.25rem;
                }

                .line-name {
                    width: 15%;
                    min-width: 1.25rem;
                }

                .item-value {
                    display: flex;
                    flex: 1;
                    min-width: 1.875rem;

                    .el-input, .el-select {
                        width: 100%;
                        height: 0.425rem;
                        line-height: 0.425rem;
                    }

                    .select-time {
                        margin: 0 0.25rem;
                    }
                }
            }
            .el-icon-document{
                font-size: 0.3rem;
                line-height: 0.425rem;
                cursor: pointer;
            }
        }
        .preserve-btn{
            text-align: center;
            padding-bottom: 0.25rem;
            border-bottom: 0.0125rem solid #ddd;
        }
        .content-area{
            flex:1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            .table-list{
                display: flex;
                flex:1;
                overflow: hidden;
                .el-table{
                    flex: 1;
                }
            }
        }
        .el-dialog{
            .dialog-content{
                display: flex;
                flex-wrap: wrap;
                padding: 0 0.625rem 0.125rem 0.375rem;
                .itemABC{
                    width:100%;
                    .item-value{
                        display: flex;
                        justify-content: space-between;
                    }
                }
                .line-item{
                    display: flex;
                    flex-direction: row;
                    margin-bottom: 0.1875rem;
                    width: 100%;
                    .item-name{
                        width: 1.25rem;
                        text-align: right;
                        line-height: 0.425rem;
                        i{
                            color: #f00;
                            padding-right: 0.0375rem;
                        }
                    }
                    .item-value{
                        flex: 1;
                        .el-input,.el-select{
                            width: 100%;
                            height: 0.425rem;
                            line-height: 0.425rem;
                        }
                    }
                    .depart-industry{
                        max-height: 3.75rem;
                        overflow-y: auto;
                    }
                }
                .line-itemW{
                    width:50%;
                }
            }
            .dialog-footer{
                text-align: center;
            }
        }
    }
</style>

<style>
    .edit-standards1 .el-table__body-wrapper{
        max-height: 4.65rem;
        height: 4.65rem;
    }
    .itemABC .item-value > .el-input:first-child,.itemABC .el-select{
        width:31% !important;
    }
</style>
